home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / os2 / cenvi2.arj / WINSET.CMD < prev    next >
OS/2 REXX Batch file  |  1993-11-06  |  4KB  |  143 lines

  1. EXTPROC CEnvi
  2. /*********************************************************
  3.  *** WinSet.cmd - CEnvi program to position, maximize, ***
  4.  ***              or hide a window                     ***
  5.  *********************************************************/
  6.  
  7. #include <PMdll.lib>
  8. #include <WinTools.lib>
  9.  
  10. #define  NO_ERROR          0     // return code from most successful DosCalls
  11.  
  12. // Initialize an array of Commands, their functions, and how many extra
  13. // arguments they require
  14. commands = { { "MIN",      "MyMinimizeWindow",     "0" },
  15.              { "MAX",      "MyMaximizeWindow",     "0" },
  16.              { "RESTORE",  "MyRestoreWindow",      "0" },
  17.              { "HIDE",     "MyHideWindow",         "0" },
  18.              { "SHOW",     "MyShowWindow",         "0" },
  19.              { "ACTIVE",   "MyActivateWindow",     "0" },
  20.              { "INACTIVE", "MyInactivateWindow",   "0" },
  21.              { "CLOSE",    "MyClose",              "0" },
  22.              { "SIZE",     "MySizeWindow",         "2" },
  23.              { "MOVE",     "MyMoveWindow",         "2" } };
  24.  
  25. main(argc,argv)
  26. {
  27.    if ( argc < 3  ||  !strcmp(argv[1],"/?")  ||  !strcmpi(argv[1],"help") ) {
  28.       Instructions();
  29.    } else if ( argc == 4  &&  !stricmp(argv[2],"TITLE") ) {
  30.       SetWindowTitle(argv[1],argv[3]);
  31.    } else {
  32.       // find the command in list of commands we know
  33.       for ( i = GetArraySpan(commands); 0 <= i; i-- ) {
  34.          command = commands[i];
  35.          if ( !stricmp(argv[2],commands[i][0]) )
  36.             break;
  37.       }
  38.       if ( i < 0  ||  argc != 3 + (ArgCount = atoi(command[2])) ) {
  39.          Instructions();
  40.       } else {
  41.          // build array of args
  42.          for ( i = 0; i < ArgCount; i++ )
  43.             Args[i] = atoi(argv[3+i]);
  44.          // send command to window
  45.          function(command[1],argv[1],
  46.                   Args[0],Args[1],Args[2],Args[3],Args[4],
  47.                   Args[5],Args[6],Args[7],Args[8],Args[9]);
  48.       }
  49.    }
  50. }
  51.  
  52. Instructions()
  53. {
  54.    printf("\a\n")
  55.    printf("WinSet - Tell a window where to go\n")
  56.    printf("\n")
  57.    printf("SYNTAX: WinSet Title MIN\n")
  58.    printf("        WinSet Title MAX\n")
  59.    printf("        WinSet Title HIDE\n")
  60.    printf("        WinSet Title SHOW\n")
  61.    printf("        WinSet Title RESTORE\n")
  62.    printf("        WinSet Title ACTIVE\n")
  63.    printf("        WinSet Title INACTIVE\n")
  64.    printf("        WinSet Title CLOSE\n")
  65.    printf("        WinSet Title SIZE Width Height\n")
  66.    printf("        WinSet Title MOVE Column Row\n")
  67.    printf("        WinSet Title TITLE NewTitle\n")
  68.    printf("\n")
  69.    printf("   Where: Title - All or partial name of a Window\n")
  70.    printf("\n");
  71.    printf("EXAMPLE: WinSet \"OS/2 Window\" MOVE 300 200\n");
  72.    printf("         WinSet \"Drive C\" TITLE \"Boot Drive\"\n")
  73.    printf("\n")
  74. }
  75.  
  76. MyMinimizeWindow(WinSpec)
  77. {
  78.    ShowWindow(WinSpec,SW_MINIMIZE);
  79. }
  80.  
  81. MyMaximizeWindow(WinSpec)
  82. {
  83.    ShowWindow(WinSpec,SW_SHOWMAXNOACTIVE);
  84. }
  85.  
  86. MyHideWindow(WinSpec)
  87. {
  88.    ShowWindow(WinSpec,SW_HIDE);
  89. }
  90.  
  91. MyShowWindow(WinSpec)
  92. {
  93.    ShowWindow(WinSpec,SW_SHOWNOACTIVATE);
  94. }
  95.  
  96. MyRestoreWindow(WinSpec)
  97. {
  98.    ShowWindow(WinSpec,SW_RESTORENOACTIVE);
  99. }
  100.  
  101. MySizeWindow(WinSpec,Width,Height)
  102. {
  103.    SetSize(WinSpec,Width,Height);
  104. }
  105.  
  106. MyMoveWindow(WinSpec,Column,Row)
  107. {
  108.    SetPosition(WinSpec,Column,Row);
  109. }
  110.  
  111. MyActivateWindow(WinSpec)
  112. {
  113.    if ( 0 != (_handle = GetWindowHandle(WinSpec)) )
  114.       SetActiveWindow(_handle);
  115. }
  116.  
  117. MyActivateWindow(WinSpec)
  118. {
  119.    if ( 0 != (_handle = GetWindowHandle(WinSpec)) )
  120.       SetActiveWindow(_handle);
  121. }
  122.  
  123. MyInactivateWindow(WinSpec)
  124. {
  125.    if ( 0 != (_handle = GetWindowHandle(WinSpec)) )
  126.       SetWindowPos(_handle,0,0,0,0,0,SWP_DEACTIVATE);
  127. }
  128.  
  129. MyClose(WinSpec)
  130. {
  131. //CloseWindow(WindowSpec)
  132. //{
  133.    if ( !(_handle = GetWindowHandle(WinSpec)) )
  134.       return(FALSE);
  135.    #define WM_CLOSE  0x0029
  136.    #define WM_QUIT                    0x002a
  137.    PostMessage(_handle,WM_QUIT,0,0);
  138.    return(TRUE);
  139. //}
  140. //   CloseWindow(WinSpec);
  141. }
  142.  
  143.